export default class Node {
    _x = 0;
    _y = 0;
    _anchorX = 0.5;
    _anchorY = 0.5;
    _width = 100;
    _height = 100;
    _children = [];
    get x() {
        return this._x;
    }
    get y() {
        return this._y;
    }
    set x(x) {
        this._x = x;
    }
    set y(y) {
        this._y = y;
    }
    get anchorX() {
        return this._anchorX;
    }
    set anchorX(value) {
        this._anchorX = value;
    }
    get anchorY() {
        return this._anchorY;
    }
    set anchorY(value) {
        this._anchorY = value;
    }
    set anchorPoint(value) {
        this.anchorX = value.x;
        this.anchorY = value.y;
    }

    get width() {
        return this._width;
    }
    set width(value) {
        this._width = value;
    }

    get height() {
        return this._height;
    }
    set height(value) {
        this._height = value;
    }

    addChild(c) {
        this._children.push(c);
    }
    update(dt) {
    }

    getVertices() {
        let x = this.x;
        let y = this.y;
        let ax = this.anchorX;
        let ay = this.anchorY;
        let w = this.width;
        let h = this.height;

        let x1 = x - w * ax;
        let x2 = x + w * (1 - ax);
        let y1 = y - h * ay;
        let y2 = y + h * (1 - ay);
        return [
            x1, y1, 0, 1,
            x2, y1, 1, 1,
            x2, y2, 1, 0,
            x2, y2, 1, 0,
            x1, y2, 0, 0,
            x1, y1, 0, 1,
        ];
    }
}